package stbm.tests;

import static org.junit.Assert.*;

import stbm.guihelpers.GameSpecifics;
import stbm.objects.Resource;
import stbm.objects.Ship;
import stbm.objects.Planet;
import stbm.objects.TradeGood;

import org.junit.Test;

/**
 * Testing the following methods:
 * 		Ship.travel(Planet source, Planet destination)
 * 
 * @author Nirav B.
 *
 */
public class NiravTest {

	Planet rojoPlanet;

	Planet azulPlanet;

	Planet amarilloPlanet;

	Ship ship;

	@Test
	public void testTravel() {

		ship = new Ship();
		Planet rojoPlanet = new Planet("Rojo", "Agriculture", new Resource(
				"MINERALRICH"), new Resource("LOTSOFWATER"), new TradeGood(
				"furs", 250.00, 250), new TradeGood("food", 100.00, 100),
				GameSpecifics.ROJO_DISTANCE);
		Planet azulPlanet = new Planet("Azul", "Early-Industrial",
				new Resource("DESERT"), new Resource("Early-Industrial"),
				new TradeGood("furs", 250.00, 250), new TradeGood("ore",
						350.00, 350), GameSpecifics.AZUL_DISTANCE);
		Planet amarilloPlanet = new Planet("Amarillo", "Industrial",
				new Resource("RICHSOIL"), new Resource("LIFELESS"),
				new TradeGood("games", 250.00, 50), new TradeGood("firearms",
						1250.00, 50), GameSpecifics.AMARILLO_DISTANCE);

		/*
		 * Ship has an initial 100 gallons of fuel
		 */
		assertEquals(ship.tank, 100);
		/*
		 * Ship can travel to a nearby planet, expending a certain amount of
		 * fuel in the process
		 */
		int initialTank = ship.tank;
		assertTrue(ship.travel(rojoPlanet, azulPlanet));
		double fuelExpended = Math.abs(GameSpecifics.ROJO_DISTANCE
				- GameSpecifics.AZUL_DISTANCE)
				* ship.GALLONS_PER_MILE;
		assertEquals((int) fuelExpended, initialTank - ship.tank);

		/*
		 * If ship has no fuel left, it can't travel to any planet
		 */
		ship.tank = 0;
		assertFalse(ship.travel(amarilloPlanet, azulPlanet));

	}

}
